<!-- 房屋管理 -->
<template>
  <div>
    <div class="header">
      <div class="title">
        <div style="float: right; width: 27%">
          <a-space style="float: right; margin-right: 10px; margin-top: 15px; margin-bottom: 15px">
            <a-button type="primary" @click="handleExport"> 导出 </a-button>
          </a-space>
        </div>
      </div>
      <a-table
        :dataSource="tableData"
        :columns="displayColumns"
        :pagination="false"
        :scroll="{ x: 1500, y: detailTableHeight }"
        bordered
        :loading="loading"
      />
      <Detail
        v-model:visible="visible"
        title="抽屉标题"
        :width="1500"
        :detailTableHeight="detailTableHeight"
        :closable="true"
        :destroyOnClose="true"
        :data="detailData"
        :detailParams="detailParams"
        :currentqx="currentqx"
        :currentTitle="currentTitle"
        @close="handleClose"
      >
        <!-- <p>抽屉内容</p> -->
      </Detail>
      <!-- <BasicTable @register="registerTable">
          <template #id="{ record }"> </template>
      </BasicTable> -->
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref, reactive, toRefs, onMounted, onBeforeMount, computed } from 'vue';
  import { getCheckYhDangerList } from '/@/api/demo/system'; //统计工作进展
  import { useUserStore } from '/@/store/modules/user';
  import { iTableData, iTableColumns } from './types/table';
  import { iParams } from './types/params';
  import Detail from './component/detailDrawer.vue';
  import { useGlobSetting } from '/@/hooks/setting';
  import { downloadByUrl } from '/@/utils/file/download';
  import { useRouter } from 'vue-router';
  const router = useRouter();
  const userStore = useUserStore();
  const globSetting = useGlobSetting();
  let userInfo = ref<any>(null);
  const visible = ref(false);
  let detailData = ref<any[]>([]);
  let detailParams = ref({}); // 详情参数
  let detailTableHeight = ref<number>(0); // 表格高度

  const yhvisible = ref(false);
  let yhdetailData = ref<any[]>([]);
  let yhdetailParams = ref({}); // 详情参数
  let yhdetailTableHeight = ref<number>(0); // 表格高度

  let tableHeight = ref<number>(0); // 表格高度
  let pageIndex = ref(1);
  let pageSize = ref(20);
  let data = reactive<{
    tableData: iTableData[];
    tableColumns: iTableColumns[];
    wscolsList: { wch: number }[];
    id: number | any;
    loading: Boolean;
    keyWorld: String;
    currentqx: string; // 当前行政区名称
    currentTitle: string;
    yhcurrentqx: string; // 当前行政区名称
    yhcurrentTitle: string;
    cityToken: string | any;
  }>({
    // 表格数据
    tableData: [],
    tableColumns: [
      {
        title: '序号',
        dataIndex: 'index',
        key: 'index',
        align: 'center',
        width: 80,
      },
      {
        title: '区县名称',
        dataIndex: 'xzq',
        key: 'xzq',
        align: 'center',
        width: 100,
        customCell: (row, index, column) => {
          let isNoHzyh = row.xzq !== '汇总' ? true : false;
          let style = 'cursor:pointer;text-decoration: underline; color: blue;';
          let isNoZero = row[column.key] !== 0 ? true : false;
          return {
            style: `${isNoHzyh === true && isNoZero ? style : ''}`,
            class: 'cell-hover',
            onClick: async () => {
              getDetailData(row, index, column, isNoHzyh, isNoZero);
            },
          };
        },
      },
      {
        title: '汇总',
        children: [
          {
            title: '隐患总数',
            dataIndex: 'yhtotal',
            key: 'yhtotal',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero, 'yhtotal', '隐患汇总', 'yh');
                },
              };
            },
          },
          {
            title: '整改数量',
            dataIndex: 'zgtotal',
            key: 'zgtotal',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'zgtotal','整改隐患汇总','zg');
                },
              };
            },
          },
          {
            title: '剩余总数',
            dataIndex: 'sytotal',
            key: 'sytotal',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'sytotal','剩余隐患汇总','sy');
                },
              };
            },
          },
        ],
        align: 'center',
        width: 170,
      },
      {
        title: '电动自行车、电动平衡车及其蓄电池在室内及安全出口处停放、充电',
        children: [
          {
            title: '隐患总数',
            dataIndex: 'use_electric_bicycle',
            key: 'use_electric_bicycle',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_electric_bicycle','电动自行车、电动平衡车及其蓄电池在室内及安全出口处停放、充电','yh');
                },
              };
            },
          },
          {
            title: '整改数量',
            dataIndex: 'use_electric_bicycle_zgcount',
            key: 'use_electric_bicycle_zgcount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_electric_bicycle','电动自行车、电动平衡车及其蓄电池在室内及安全出口处停放、充电','zg');
                },
              };
            },
          },
          {
            title: '剩余总数',
            dataIndex: 'use_electric_bicycle_sycount',
            key: 'use_electric_bicycle_sycount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_electric_bicycle','电动自行车、电动平衡车及其蓄电池在室内及安全出口处停放、充电','sy');
                },
              };
            },
          },
        ],
        align: 'center',
        width: 170,
      },
      {
        title: '在公共区域、租住房间内、地下室使用瓶装液化石油气',
        children: [
          {
            title: '隐患总数',
            dataIndex: 'use_bottled_liquefied_gas',
            key: 'use_bottled_liquefied_gas',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_bottled_liquefied_gas','在公共区域、租住房间内、地下室使用瓶装液化石油气','yh');
                },
              };
            },
          },
          {
            title: '整改数量',
            dataIndex: 'use_bottled_liquefied_gas_zgcount',
            key: 'use_bottled_liquefied_gas_zgcount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_bottled_liquefied_gas','在公共区域、租住房间内、地下室使用瓶装液化石油气','zg');
                },
              };
            },
          },
          {
            title: '剩余总数',
            dataIndex: 'use_bottled_liquefied_gas_sycount',
            key: 'use_bottled_liquefied_gas_sycount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_bottled_liquefied_gas','在公共区域、租住房间内、地下室使用瓶装液化石油气','sy');
                },
              };
            },
          },
        ],
        align: 'center',
        width: 170,
      },
      // 居住 商业
      {
        title: '疏散走道、楼梯间、安全出口处堆放物品影响人员疏散',
        children: [
          {
            title: '隐患总数',
            dataIndex: 'use_stacked_items',
            key: 'use_stacked_items',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_stacked_items','疏散走道、楼梯间、安全出口处堆放物品影响人员疏散','yh');
                },
              };
            },
          },
          {
            title: '整改数量',
            dataIndex: 'use_stacked_items_zgcount',
            key: 'use_stacked_items_zgcount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_stacked_items','疏散走道、楼梯间、安全出口处堆放物品影响人员疏散','zg');
                },
              };
            },
          },
          {
            title: '剩余总数',
            dataIndex: 'use_stacked_items_sycount',
            key: 'use_stacked_items_sycount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'use_stacked_items','疏散走道、楼梯间、安全出口处堆放物品影响人员疏散','sy');
                },
              };
            },
          },
        ],
        align: 'center',
        width: 170,
      },
      // 居住 商业
      {
        title: '私拉乱接电线',
        children: [
          {
            title: '隐患总数',
            dataIndex: 'slljdx',
            key: 'slljdx',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'slljdx','私拉乱接电线','yh');
                },
              };
            },
          },
          {
            title: '整改数量',
            dataIndex: 'slljdx_zgcount',
            key: 'slljdx_zgcount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'slljdx','私拉乱接电线','zg');
                },
              };
            },
          },
          {
            title: '剩余总数',
            dataIndex: 'slljdx_sycount',
            key: 'slljdx_sycount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'slljdx','私拉乱接电线','sy');
                },
              };
            },
          },
        ],
        align: 'center',
        width: 170,
      },
      //  商业
      {
        title: '灭火器未保持完好有效',
        children: [
          {
            title: '隐患总数',
            dataIndex: 'mhqwbcwhyx',
            key: 'mhqwbcwhyx',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'mhqwbcwhyx','灭火器未保持完好有效','yh');
                },
              };
            },
          },
          {
            title: '整改数量',
            dataIndex: 'mhqwbcwhyx_zgcount',
            key: 'mhqwbcwhyx_zgcount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'mhqwbcwhyx','灭火器未保持完好有效','zg');
                },
              };
            },
          },
          {
            title: '剩余总数',
            dataIndex: 'mhqwbcwhyx_sycount',
            key: 'mhqwbcwhyx_sycount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'mhqwbcwhyx','灭火器未保持完好有效','sy');
                },
              };
            },
          },
        ],
        dataIndex: 'mhqwbcwhyx',
        key: 'mhqwbcwhyx',
        align: 'center',
        width: 170,
      },
      {
        title: '简易喷淋灭火系统未保持完好有效',
        children: [
          {
            title: '隐患总数',
            dataIndex: 'jyplmhxtwbcwhyx',
            key: 'jyplmhxtwbcwhyx',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'jyplmhxtwbcwhyx','简易喷淋灭火系统未保持完好有效','yh');
                },
              };
            },
          },
          {
            title: '整改数量',
            dataIndex: 'jyplmhxtwbcwhyx_zgcount',
            key: 'jyplmhxtwbcwhyx_zgcount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'jyplmhxtwbcwhyx','简易喷淋灭火系统未保持完好有效','zg');
                },
              };
            },
          },
          {
            title: '剩余总数',
            dataIndex: 'jyplmhxtwbcwhyx_sycount',
            key: 'jyplmhxtwbcwhyx_sycount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'jyplmhxtwbcwhyx','简易喷淋灭火系统未保持完好有效','sy');
                },
              };
            },
          },
        ],
        align: 'center',
        width: 170,
      },
      {
        title: '烟感报警器未保持完好有效',
        children: [
          {
            title: '隐患总数',
            dataIndex: 'ygbjwfwhyx',
            key: 'ygbjwfwhyx',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'ygbjwfwhyx','烟感报警器未保持完好有效','yh');
                },
              };
            },
          },
          {
            title: '整改数量',
            dataIndex: 'ygbjwfwhyx_zgcount',
            key: 'ygbjwfwhyx_zgcount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'ygbjwfwhyx','烟感报警器未保持完好有效','zg');
                },
              };
            },
          },
          {
            title: '剩余总数',
            dataIndex: 'ygbjwfwhyx_sycount',
            key: 'ygbjwfwhyx_sycount',
            width: 100,
            align: 'center',
            customCell: (row, index, column) => {
              let isNoHzyh = row.xzq !== '汇总' ? true : false;
              let style = 'cursor:pointer;text-decoration: underline; color: blue;';
              let isNoZero = row[column.key] !== 0 ? true : false;
              return {
                style: `${isNoHzyh === true && isNoZero ? style : ''}`,
                class: 'cell-hover',
                onClick: async () => {
                  getDetailYhData(row, index, column, isNoHzyh, isNoZero,'ygbjwfwhyx','烟感报警器未保持完好有效','sy');
                },
              };
            },
          },
        ],
        align: 'center',
        width: 170,
      },
    ],
    id: null,
    loading: true,
    keyWorld: '',
    cityToken: '', // 判断是不是市区 110000 是北京市 展示搜索宽
    currentqx: '', // 当前行政区名称
    currentTitle: '', // 当前详情标题
    yhcurrentqx: '', //
    yhcurrentTitle: '', //
    wscolsList: [{ wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }],
  });
  // 表格的 ref Dom名称
  let { tableData, loading, currentqx, currentTitle, yhcurrentqx, yhcurrentTitle } = toRefs(data);
  async function getData() {
    const { role } = userInfo.value;
    let groupname = '';
    if (role === 'City') {
      groupname = 'qxmc';
    } else if (role === 'Area') {
      groupname = 'jzmc';
    } else if (role === 'Street') {
      groupname = 'czmc';
    }
    let params: iParams = {
      groupname: groupname,
    };
    // console.log('@市级参数', params);
    loading.value = true;
    let res: any = await getCheckYhDangerList(params);
    console.log('@res--工作进入汇总表', res);

    if (res || res.items.length > 0) {
      loading.value = false;
      res.items.forEach((item: any, index: number) => {
        // item.name = selectClassFlyDict(item.xzqdm);
        item.index = index + 1;
      });
      // console.log('data', data);
      // 算列和
      
      let yhtotal = total(res.items, 'yhtotal');
      let zgtotal = total(res.items, 'zgtotal');
      let sytotal = total(res.items, 'sytotal');
      let use_electric_bicycle_count = total(res.items, 'use_electric_bicycle');
      let use_bottled_liquefied_gas_count = total(res.items, 'use_bottled_liquefied_gas');
      let use_stacked_items_count = total(res.items, 'use_stacked_items');
      let index_count = res.items.length + 1;
      let mhqwbcwhyx_count = total(res.items, 'mhqwbcwhyx');
      let jyplmhxtwbcwhyx_count = total(res.items, 'jyplmhxtwbcwhyx');
      let ygbjwfwhyx_count = total(res.items, 'ygbjwfwhyx');
      let slljdx_count = total(res.items, 'slljdx');

      let use_electric_bicycle_count_zgcount = total(res.items, 'use_electric_bicycle_zgcount');
      let use_bottled_liquefied_gas_count_zgcount = total(
        res.items,
        'use_bottled_liquefied_gas_zgcount',
      );
      let use_stacked_items_count_zgcount = total(res.items, 'use_stacked_items_zgcount');
      let mhqwbcwhyx_count_zgcount = total(res.items, 'mhqwbcwhyx_zgcount');
      let jyplmhxtwbcwhyx_count_zgcount = total(res.items, 'jyplmhxtwbcwhyx_zgcount');
      let ygbjwfwhyx_count_zgcount = total(res.items, 'ygbjwfwhyx_zgcount');
      let slljdx_count_zgcount = total(res.items, 'slljdx_zgcount');

      let use_electric_bicycle_count_sycount = total(res.items, 'use_electric_bicycle_sycount');
      let use_bottled_liquefied_gas_count_sycount = total(
        res.items,
        'use_bottled_liquefied_gas_sycount',
      );
      let use_stacked_items_count_sycount = total(res.items, 'use_stacked_items_sycount');
      let mhqwbcwhyx_count_sycount = total(res.items, 'mhqwbcwhyx_sycount');
      let jyplmhxtwbcwhyx_count_sycount = total(res.items, 'jyplmhxtwbcwhyx_sycount');
      let ygbjwfwhyx_count_sycount = total(res.items, 'ygbjwfwhyx_sycount');
      let slljdx_count_sycount = total(res.items, 'slljdx_sycount');

      let allObj = {
        xzq: '汇总',
        yhtotal: yhtotal,
        zgtotal: zgtotal,
        sytotal: sytotal,
        use_electric_bicycle: use_electric_bicycle_count,
        use_bottled_liquefied_gas: use_bottled_liquefied_gas_count,
        use_stacked_items: use_stacked_items_count,
        index: index_count,
        mhqwbcwhyx: mhqwbcwhyx_count,
        jyplmhxtwbcwhyx: jyplmhxtwbcwhyx_count,
        ygbjwfwhyx: ygbjwfwhyx_count,
        slljdx: slljdx_count,

        use_electric_bicycle_zgcount: use_electric_bicycle_count_zgcount,
        use_bottled_liquefied_gas_zgcount: use_bottled_liquefied_gas_count_zgcount,
        use_stacked_items_zgcount: use_stacked_items_count_zgcount,
        mhqwbcwhyx_zgcount: mhqwbcwhyx_count_zgcount,
        jyplmhxtwbcwhyx_zgcount: jyplmhxtwbcwhyx_count_zgcount,
        ygbjwfwhyx_zgcount: ygbjwfwhyx_count_zgcount,
        slljdx_zgcount: slljdx_count_zgcount,

        use_electric_bicycle_sycount: use_electric_bicycle_count_sycount,
        use_bottled_liquefied_gas_sycount: use_bottled_liquefied_gas_count_sycount,
        use_stacked_items_sycount: use_stacked_items_count_sycount,
        mhqwbcwhyx_sycount: mhqwbcwhyx_count_sycount,
        jyplmhxtwbcwhyx_sycount: jyplmhxtwbcwhyx_count_sycount,
        ygbjwfwhyx_sycount: ygbjwfwhyx_count_sycount,
        slljdx_sycount: slljdx_count_sycount,
      };
      data.tableData = [...res.items, allObj];
    }
  }
  // 计算总数的方法
  function total(arr: any, item: any) {
    let total = arr.reduce((pre: any, cur: any) => {
      return parseInt(pre) + parseInt(cur[item]);
    }, 0);
    return total;
  }

  const getDetailData = async (
    row: any,
    index: number,
    column: any,
    isNoHzyh: boolean,
    isNoZero: boolean,
  ) => {
    if (isNoHzyh && isNoZero) {
      let params: iParams = {
        groupbyLever_code: row.xzqdm,
        groupbyLever_code_project: column.key,
        xzq: row.xzq,
      };
      detailParams.value = params;
      data.currentTitle = row.xzq;
      showDrawer();
    }
  };

  const getDetailYhData = async (
    row: any,
    index: number,
    column: any,
    isNoHzyh: boolean,
    isNoZero: boolean,
    check_id: string,
    check_name: string,
    type: string,
  ) => {
    if (isNoHzyh && isNoZero) {
      router.push({
        path: 'hourseCheckYhDetailLog',
        query: {
          groupbyLever_code: row.xzqdm,
          groupbyLever_code_project: column.key,
          check_id: check_id,
          xzqdm: row.xzqdm,
          xzq: row.xzq,
          type: type,
          check_name: check_name,
          yhly:'5'
        },
      });
    }
  };
  function showyhDrawer() {
    yhvisible.value = true;
  }
  function handleyhClose() {
    yhvisible.value = false;
  }
  // 打开抽屉
  function showDrawer() {
    visible.value = true;
  }
  function handleClose() {
    visible.value = false;
  }

  function getUserInfo() {
    const userStore = useUserStore();
    userInfo.value = userStore?.getUserInfo;
  }
  const displayColumns = computed(() => {
    const { role } = userInfo.value;
    let arr: any[] = [];
    if (role === 'City') {
      // qx
      arr = data.tableColumns.filter((item) => item.key !== 'jzmc' && item.key !== 'czmc');
      return arr;
    } else if (role === 'Area') {
      // jz
      arr = data.tableColumns.filter((item) => item.key !== 'czmc' && item.key !== 'qxmc');
      return arr;
    } else if (role === 'Street') {
      // cun
      arr = data.tableColumns.filter((item) => item.key !== 'jzmc' && item.key !== 'qxmc');
      console.log('@Aarr', arr);
      return arr;
    } else {
      return data.tableColumns;
    }
  });
  function handleExport() {
    const uriBase = `${globSetting.apiBaseUrl}${globSetting.apiUrl}`;
    const tk = userStore.getToken;
    downloadByUrl({
      url: uriBase + '/export/static/yhExport?access_token=' + tk + '&category=jc&levle=xzq',
      target: '_blank',
    });
  }
  const getTableHeight = () => {
    setTimeout(() => {
      // detailTableHeight.value = window.innerHeight - 182;
      // tableHeight.value = window.innerHeight - 292;
      detailTableHeight.value = window.innerHeight - 182;
      yhdetailTableHeight.value = window.innerHeight;
      tableHeight.value = window.innerHeight;
      // console.log(`表格高度`, tableHeight.value);
    });
  };
  onBeforeMount(() => {
    getUserInfo();
  });
  onMounted(() => {
    console.log('******隐患信息统计初始化******');
    getData();
    getTableHeight();
  });
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
  #map {
    height: calc(100vh - 140px);
  }

  .x-houseMng-search {
    z-index: 100;
    margin: 6px;
    position: absolute;
  }

  .root-house-mng-main {
    margin: 6px;
  }

  .x-village-tabs {
    //z-index: 100;
    //position: absolute;
    width: 60vw;
    margin-top: 6px;
    margin-left: 40px;
    //background-color: rgba(34, 34, 34, 0.6);
    :deep(.ant-form) {
      margin-top: 6px;
    }

  }
  .ant-table-thead > tr > th,
    .ant-table-tbody > tr > td,
    .ant-table tfoot > tr > th,
    .ant-table tfoot > tr > td {
      padding: 13px 16px !important;
    }
</style>
